package com.wdy.service.impl;

import java.util.List;

import com.wdy.dao.ChargeDao;
import com.wdy.po.Charge;
import com.wdy.po.Page;
import com.wdy.po.Result;
import com.wdy.service.ChargeManager;
import com.wdy.util.PageUtil;

public class ChargeManagerImpl implements ChargeManager {

	private ChargeDao chargeDao;
	
	public void setChargeDao(ChargeDao chargeDao) {
		this.chargeDao = chargeDao;
	}

	
	public void saveCharge(Charge charge) {
		chargeDao.save(charge);
	}

	
	public void removeCharge(Charge charge) {
		chargeDao.delete(charge);
	}

	
	public void updateCharge(Charge charge) {
		chargeDao.attachDirty(charge);
	}

	
	public Charge getCharge(Integer id) {
		return chargeDao.findById(id);
	}


	public List<Charge> listAll() {
		return chargeDao.findAll();
	}

	
	public List<Charge> findByExample(Charge charge) {
		return chargeDao.findByExample(charge);
	}


	public List<Charge> findByDate(String value) {
		return chargeDao.findByDate(value);
	}


	public Result listCharge(Page page) {
		int totalRecords = this.chargeDao.getChargeCount();
		page = PageUtil.createPage(page, totalRecords);
		List<Charge> charges = (List<Charge>)this.chargeDao.getChargeByPage(page);     
		return new Result(page, charges);
	}

}
